<?php
$path=set_include_path("/var/www/Miscore/");
include_once 'clases_php/MiScore.php';
include_once 'daos/mysqlConection.php';
include_once 'pruebas_unitarias/funciones.php';
set_include_path($path);

class crearCalendarioTest extends PHPUnit_Framework_TestCase{
	public $miscore;
	public $db;
	public $torneo;

	public function setUp(){
		$this->miscore=new MiScore();
		$this->db = new mysqlConection();
		$this->torneo=crearTorneo();
		agregarEquipos($this->torneo->nombre, traerEquipos(6));
	}

	public function tearDown(){

	}

	public function testCalcularJornadas(){
		$this->assertTrue($this->torneo->calcularJornadas(3)==3);
		$this->assertTrue($this->torneo->calcularJornadas(4)==3);
		$this->assertTrue($this->torneo->calcularJornadas(5)==5);
		$this->assertTrue($this->torneo->calcularJornadas(6)==5);
		$this->assertTrue($this->torneo->calcularJornadas(7)==7);
		$this->assertTrue($this->torneo->calcularJornadas(8)==7);
		$this->assertTrue($this->torneo->calcularJornadas(100)==99);
		$this->assertTrue($this->torneo->calcularJornadas(101)==101);
		$this->assertTrue($this->torneo->calcularJornadas(1000)==999);
		$this->assertTrue($this->torneo->calcularJornadas(1001)==1001);
	}

	/**
	 * Crear un calendario para un torneo nuevo
	 *
	 */
	public function testCrearCrearCalendario(){
		$partidos=array();
		$partidos[]=new Partido("01/01/2011");

		$partidos[]=new Partido("02/01/2011");

		$partidos[]=new Partido("03/01/2011");

		$partidos[]=new Partido("04/01/2011");

		$partidos[]=new Partido("05/01/2011");
		$a=$this->miscore->administradorTorneo->torneoDaoImpl->crearPartidos($this->torneo->idTorneo, $partidos);
		$this->assertTrue($a!=null);
	}



}
?>